/**
 * @file:          Foc.h
 * @brief:
 * @details:
 * @author:        wjh
 * @date created:  2023.06.14
 * @version:       1.0.0
 * @par copyright (c):
 *
 * @par history (desc):
 *   version:1.0.0, wjh, 2023.06.14,01:34:52
 */

#ifndef _FOC_H_
#define _FOC_H_

/* Include Files **************************************************************/
#include "Datatype.h"

/* Macro Definition ***********************************************************/

/* Data Type Define ***********************************************************/
enum CLARK_MODE
{
    CLARK_MODE_EQUAL_AMPLITUDE_TRANSFORM,
    CLARK_MODE_EQUAL_POWER_TRANSFORM,
};
typedef struct Foc
{
    /* public data */
    enum CLARK_MODE param_clark_mode;
    float32 k_clark;
    float32 ud;
    float32 uq;
    float32 theta;
    float32 ualpha;
    float32 ubeta;
    float32 ia;
    float32 ib;
    float32 ic;
    float32 ialpha;
    float32 ibeta;
    float32 id;
    float32 iq;

    /* private data */

    /* public method */
    uint8 (*Init)(struct Foc *self);
    void (*Clark)(float32 A, float32 B, float32 C, float32 *alpha, float32 *beta);
    void (*IClark)(float32 alpha, float32 beta, float32 *A, float32 *B, float32 *C);
    void (*Park)(float32 alpha, float32 beta, float32 theta, float32 *d, float32 *q) __REENTRANT__;
    void (*IPark)(float32 d, float32 q, float32 theta, float32 *alpha, float32 *beta) __REENTRANT__;
    void (*SetClarkMode)(struct Foc *self, enum CLARK_MODE clark_mode);

    /* private method */

} Foc;

/* Variable Declare ***********************************************************/

/* Function Declare ***********************************************************/
uint8 Foc_Init(struct Foc *self);
void Foc_Clark(float32 A, float32 B, float32 C, float32 *alpha, float32 *beta);
void Foc_IClark(float32 alpha, float32 beta, float32 *A, float32 *B, float32 *C);
void Foc_Park(float32 alpha, float32 beta, float32 theta, float32 *d, float32 *q);
void Foc_IPark(float32 d, float32 q, float32 theta, float32 *alpha, float32 *beta);
void Foc_SetClarkMode(Foc *self, enum CLARK_MODE clark_mode);

#endif